package com.itheima01;

import java.sql.*;
import java.text.SimpleDateFormat;

public class Demo02 {
    public static void main(String[] args)  {
        Connection con=null;
        Statement stat=null;

        try {
            Class.forName("com.mysql.jdbc.Driver");
            con= DriverManager.getConnection("jdbc:mysql://localhost:3307/db2","root","root");
            stat = con.createStatement();
            String sql="INSERT INTO student VALUES(5,'刘天',23,'男',100)";
            int i = stat.executeUpdate(sql);
            System.out.println(i);
        } catch (Exception e) {
            e.printStackTrace();
        }
         finally {
            if (con !=null){
                try {
                    con.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
            if (stat!=null){
                try {
                    stat.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
